<script setup lang="ts">

 import { User,Lock } from '@element-plus/icons-vue'
 import useLogin from "../hooks/useLogin"

  const { 
    agreed,
    loginForm,
    loginFormRef,
    rules,
    login, 
  } = useLogin();

</script>

<template>
   <el-card class="Page" shadow="hover" >
          <el-form class="form" :model="loginForm" ref="loginFormRef" autocomplete="off" :rules="rules">
            <!-- 标题 -->
            <el-form-item class="title">
              <h1>账号登录</h1>
            </el-form-item>
            <!-- 账号 -->
            <el-form-item class="input" prop="username">
              <el-input  v-model="loginForm.username" placeholder="请输入手机号" :prefix-icon="User" size="large"></el-input>
            </el-form-item>
            <!-- 密码 -->
            <el-form-item class="input" prop="password">
              <el-input  v-model="loginForm.password" type="password" show-password placeholder="请输入密码" :prefix-icon="Lock" size="large"></el-input>
            </el-form-item>
            <!-- 按钮 -->
            <el-form-item class="button">
              <el-button size="large" style="width: 100%;" @click="login">登录</el-button>
            </el-form-item>
            <!-- 协议声明 -->
            <div class="protocol">
              <el-checkbox size="large" v-model="agreed" />
              <span>已阅读并同意</span>
              <el-link type="primary" :underline="false">《用户协议》</el-link>
              <el-link type="primary" :underline="false">《隐私政策》</el-link>
            </div>
          </el-form>
        </el-card>
</template>

<style lang = scss scoped>
   .Page{ 
          position: absolute;
          height: 65%;
          width: 76%;
          background-color: #F7F2EB;
          left: 50%;
          top: 50%;
          transform: translate(-50%,-50%);
          border-radius:20px;
          border: 1px solid #BBB;
          .form{
            flex-direction: column;
            justify-content: center;
            user-select: none;
            margin: 0 2.5rem;

            :deep(.el-form-item__content){
              border-radius: 20px;
            }

            .title{
              margin-top: 0.65rem;
              width: 100%;
              text-align: center;
              h1 {
                margin: 0; /* 新增 */
                padding: 0; /* 新增 */
                width: 100%; /* 新增 */
                color: #5A3E2F;
                letter-spacing: 2px;
              }
            }

            .input{
              width: 100%;
            // 输入框全局样式
            :deep(.el-input) {
              // 修改 placeholder
              margin-top:0.2rem ;
              border-radius: 10px;
              .el-input__inner::placeholder {
                color: #A09387;
                opacity: 0.8;
                font-size: 16px;
              }   

              
              // 修改图标
              .el-input__prefix {
                .el-icon {
                  color: #5A3E2F;
                  font-size: 1rem;
                  margin-right: 0.5rem;
                }
              }
              
              // 输入框本身样式
              .el-input__inner {
                background-color: rgba(247, 242, 235, 0.7);
                color: #5A3E2F;
                padding-left: 1.5rem;
                
                &:focus {
                  border-color: #5A3E2F;
                  box-shadow: 0 0 0 2px rgba(90, 62, 47, 0.2);
                }
              }
              
              // 密码可见性切换图标
              .el-input__suffix {
                .el-icon {
                  color: #5A3E2F;
                  font-size: 1rem;
                  cursor: pointer;
                }
              }
            }
          }
          
          .button {
            :deep(.el-button) {
              margin-top: 1rem;
              background-color: #5A3E2F;
              color: #F7F2EB;
              font-weight: bold;
              border: none;
              height: 2rem;
              font-size: 1rem;
              border-radius: 12px;
              letter-spacing: 1px;
              transition: all 0.3s;

              &:hover {
                background-color: #7A5E4F;
                transform: translateY(-2px);
                box-shadow: 0 4px 8px rgba(90, 62, 47, 0.25);
              }

              &:active {
                transform: translateY(1px);
              }
            }
          }
        }
      }
  //同意协议
    .protocol {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #606266;
    font-size: 0.8rem;

    .el-checkbox {
      margin-right: 0.3rem;
    }

    .el-link {
      margin: 0 0.2rem;
    }
  }



</style>
